# -*- coding: utf-8 -*-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#作者：cacho_37967865
#博客：https://blog.csdn.net/sinat_37967865
#文件：files_select.py
#日期：2019-10-18
#备注： 获取批量的文件
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

import glob
import os


def get_files(file_path,type):
    all_info = file_path + '*.' + type
    jd_all = glob.glob(all_info)
    #print(jd_all)
    return jd_all


# 递归所有目录、或者文件 type：dir 取目录、file 取文件
def get_all_files(file_path,type,file_type):
    all_info = file_path + '**'
    jd_all = glob.glob(all_info,recursive=True)
    files = []
    dirs =[]
    for info in jd_all:
        if os.path.isdir(info) :
            dirs.append(info)
        elif os.path.isfile(info) and file_type in info :
            files.append(info)
        else:
            print(info,"it's a special file(socket,FIFO,device file)")
    if type == 'dir':
        return dirs
    elif type == 'file':
        #print(files)
        return files

if __name__ == '__main__':
    #get_files('F:\image\\', 'mp4')
    get_all_files('F:\image\\temp\\', 'file','jpg')
